﻿@model IEnumerable< BattleThis.Core.Game >
@{
    ViewBag.Title = "Index";
}

<h2>Welcome to BattleThis</h2>
<p>This will be the lobby where you choose your games to play.</p>

<table>
    <thead>
        <tr>
            <th>Name</th>
            <th>Map</th>
            <th>Size(Rows/Columns)</th>
            <th>Current Player</th>
            <th>Players</th>
            <th>Action</th>
        </tr>
    </thead>
    <tbody>
        @foreach( var game in this.Model )
        {
            <tr>
                <td>@game.Name</td>
                <td>@game.Map.Name</td>
                <td>@game.Map.Size.ToString()</td>
                <td>@game.CurrentPlayer.Name</td>
                <td>@string.Format("{0}/{1}", game.Players.Count(), game.Map.MaxPlayer)</td>
                <td>
                    @if( game.IsReady() ) 
                    { @Html.ActionLink( "Enter", BattleThis.Controllers.LobbyController.LoadAction, new { id = game.Id } ) }
                    else 
                    { 
                      @Html.ActionLink( "Wait for Players join the game", BattleThis.Controllers.LobbyController.JoinAction, new { id = game.Id } )
                    }
                </td>
            </tr>
        }
    </tbody>
</table>

<p>Create a new game here</p>
@Html.ActionLink( "Create", BattleThis.Controllers.LobbyController.CreateAction )
